package gui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.JPanel;

import tool.CustomizedButton;

import controller.gui.mainmenu.BackgroundWizardController;
import controller.gui.mainmenu.DeleteMapElementController;
import controller.gui.mainmenu.DownCurrentStrataWizardController;
import controller.gui.mainmenu.MapLayerWizardController;
import controller.gui.mainmenu.MapObjectWizardController;
import controller.gui.mainmenu.MapPropertiesWizardController;
import controller.gui.mainmenu.MapStrataWizardController;
import controller.gui.mainmenu.UpCurrentStrataWizardController;

/** Si tratta del JPanel localizzato a sinistra dell'Editor,
 * sede del menu di navigazione primario.
 * @author Daniele
 * @version 1.4 */
public class PrimaryMenu extends JPanel {

	private static final long serialVersionUID = 8788167039986260935L;
	
	// Scritte dei pulsanti di questo menu.
	private static final String MAP_TXT = "Map Specs";
	private static final String BKG_TXT = "Background";
	private static final String UP_TXT = "Up";
	private static final String DWN_TXT = "Down";
	private static final String STR_TXT = "Strata";
	private static final String LYR_TXT = "MapLayers";
	private static final String OBJ_TXT = "MapObjects";
	private static final String DEL_TXT = "Delete";
	
	/** Il layout utilizzato per disporre i vari componenti contenuti nel JPanel. */
	private GridBagLayout layout;
	/** I constraints relativi al GridBagLayout. */
	private GridBagConstraints constraints;
	/** Il pulsante MAP del PrimaryMenu. */
	private CustomizedButton map_button;
	/** Il pulsante BACKGROUND del PrimaryMenu. */
	private CustomizedButton bkg_button;
	/** Il pulsante UP del PrimaryMenu. */
	private CustomizedButton up_button;
	/** Il pulsante DOWN del PrimaryMenu. */
	private CustomizedButton dwn_button;
	/** Il pulsante STRATA del PrimaryMenu. */
	private CustomizedButton str_button;
	/** Il pulsante LAYER del PrimaryMenu. */
	private CustomizedButton lyr_button;
	/** Il pulsante OBJECT del PrimaryMenu. */
	private CustomizedButton obj_button;
	/** Il pulsante DELETE del PrimaryMenu. */
	private CustomizedButton del_button;
	
//	public void addListeners(MapPropertiesWizardController editmap,BackgroundWizardController background,MapLayerWizardController ml,MapObjectWizardController mo,MapStrataWizardController sw, DownCurrentStrataWizardController downstratum, UpCurrentStrataWizardController upstratum, DeleteMapElementController delete){
//		editmap.wire(map_button);
//		background.wire(bkg_button);
//		ml.wire(lyr_button);
//		mo.wire(obj_button);
//		sw.wire(str_button);
//		downstratum.wire(dwn_button);
//		upstratum.wire(up_button);
//		delete.wire(del_button);
//	}
	
	/** Costruisce graficamente il modello di menu di navigazione
	 *  primario, come da progetto, completo di tutti i suoi componenti. */
	public PrimaryMenu(){
		
		super();
		
		layout = new GridBagLayout();
		constraints = new GridBagConstraints();
		this.setLayout(layout);
		
		map_button = new CustomizedButton(PrimaryMenu.MAP_TXT,20,Color.WHITE,Color.BLUE,Color.WHITE,Color.BLUE,new Color(50,0,200),Color.GREEN,3,"Britannic Bold",Color.BLUE,Color.WHITE,Color.GREEN);
		this.addComponentToLayout(map_button, 0);
		
		bkg_button = new CustomizedButton(PrimaryMenu.BKG_TXT,20,Color.WHITE,Color.BLUE,Color.WHITE,Color.BLUE,new Color(50,0,200),Color.GREEN,3,"Britannic Bold",Color.BLUE,Color.WHITE,Color.GREEN);
		this.addComponentToLayout(bkg_button, 1);
		
		up_button = new CustomizedButton(PrimaryMenu.UP_TXT,20,Color.WHITE,Color.BLUE,Color.WHITE,Color.BLUE,new Color(50,0,200),Color.GREEN,3,"Britannic Bold",Color.BLUE,Color.WHITE,Color.GREEN);
		this.addComponentToLayout(up_button, 2);
		
		dwn_button = new CustomizedButton(PrimaryMenu.DWN_TXT,20,Color.WHITE,Color.BLUE,Color.WHITE,Color.BLUE,new Color(50,0,200),Color.GREEN,3,"Britannic Bold",Color.BLUE,Color.WHITE,Color.GREEN);;
		this.addComponentToLayout(dwn_button, 3);
		
		str_button = new CustomizedButton(PrimaryMenu.STR_TXT,20,Color.WHITE,Color.BLUE,Color.WHITE,Color.BLUE,new Color(50,0,200),Color.GREEN,3,"Britannic Bold",Color.BLUE,Color.WHITE,Color.GREEN);
		this.addComponentToLayout(str_button, 4);
		
		lyr_button = new CustomizedButton(PrimaryMenu.LYR_TXT,20,Color.WHITE,Color.BLUE,Color.WHITE,Color.BLUE,new Color(50,0,200),Color.GREEN,3,"Britannic Bold",Color.BLUE,Color.WHITE,Color.GREEN);
		this.addComponentToLayout(lyr_button, 5);
		
		obj_button = new CustomizedButton(PrimaryMenu.OBJ_TXT,20,Color.WHITE,Color.BLUE,Color.WHITE,Color.BLUE,new Color(50,0,200),Color.GREEN,3,"Britannic Bold",Color.BLUE,Color.WHITE,Color.GREEN);
		this.addComponentToLayout(obj_button, 6);
		
		del_button = new CustomizedButton(PrimaryMenu.DEL_TXT,20,Color.WHITE,new Color(250,50,50),Color.WHITE,new Color(250,50,50),Color.RED,Color.GREEN,3,"Britannic Bold",new Color(250,50,50),Color.WHITE,Color.GREEN);
		this.addComponentToLayout(del_button, 7);
	}
	
	/** Metodo che riassume le operazioni da effettuare per registrare un pulsante
	 *  nel PrimaryMenu, in accordo con il layout scelto.
	 * @param b     il pulsante da registrare.
	 * @param order intero che rappresenta la posizione in ordine crescente. */
	private void addComponentToLayout(CustomizedButton b, int order){
		constraints.gridx = 0;
		constraints.gridy = order;
		constraints.weightx = 1;
		constraints.weighty = 1;
		constraints.anchor = GridBagConstraints.CENTER;
		constraints.fill = GridBagConstraints.BOTH;
		constraints.insets.top = 10;
		constraints.insets.bottom = 10;
		constraints.insets.left = 30;
		constraints.insets.right = 30;
		layout.setConstraints(b, constraints);
		this.add(b, constraints);
	}
	
	public void paintComponent(Graphics g){
		Dimension size = this.getSize();
		RoundedBorder border = new RoundedBorder(Color.LIGHT_GRAY, Color.WHITE, 3, 40);
		border.paintBorder(this, g, 0, 0, size.width, size.height);
	}

	/**
	 * @return the layout. For further information visit {@link #layout}
	 */
	public GridBagLayout getLayout() {
		return layout;
	}

	/**
	 * @return the constraints. For further information visit {@link #constraints}
	 */
	public GridBagConstraints getConstraints() {
		return constraints;
	}

	/**
	 * @return the map_button. For further information visit {@link #map_button}
	 */
	public CustomizedButton getMap_button() {
		return map_button;
	}

	/**
	 * @return the bkg_button. For further information visit {@link #bkg_button}
	 */
	public CustomizedButton getBkg_button() {
		return bkg_button;
	}

	/**
	 * @return the up_button. For further information visit {@link #up_button}
	 */
	public CustomizedButton getUp_button() {
		return up_button;
	}

	/**
	 * @return the dwn_button. For further information visit {@link #dwn_button}
	 */
	public CustomizedButton getDwn_button() {
		return dwn_button;
	}

	/**
	 * @return the str_button. For further information visit {@link #str_button}
	 */
	public CustomizedButton getStr_button() {
		return str_button;
	}

	/**
	 * @return the lyr_button. For further information visit {@link #lyr_button}
	 */
	public CustomizedButton getLyr_button() {
		return lyr_button;
	}

	/**
	 * @return the obj_button. For further information visit {@link #obj_button}
	 */
	public CustomizedButton getObj_button() {
		return obj_button;
	}

	/**
	 * @return the del_button. For further information visit {@link #del_button}
	 */
	public CustomizedButton getDel_button() {
		return del_button;
	}
	
	
}
